package cloud.daodao.storm.security.controller;

import cloud.daodao.storm.common.security.model.aes.AesCipherData;
import cloud.daodao.storm.common.security.model.aes.AesCipherParam;
import cloud.daodao.storm.security.service.AesService;
import cloud.daodao.storm.common.security.api.AesApi;
import cloud.daodao.storm.common.model.Request;
import cloud.daodao.storm.common.model.Response;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DaoDao
 */
@RestController
public class AesController implements AesApi {

    @Resource
    private AesService aesService;

    @Override
    public Response<AesCipherData> aesEncrypt(@RequestBody @Valid Request<AesCipherParam> request) {
        AesCipherData data = aesService.aesEncrypt(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<AesCipherData> aesDecrypt(@RequestBody @Valid Request<AesCipherParam> request) {
        AesCipherData data = aesService.aesDecrypt(request.getParam());
        return new Response<>(data);
    }

}
